<template>
  <div class="app-container">
    <el-form  :inline="true" label-width="80px">
      <el-form-item label="年份检索">
        <el-date-picker v-model="queryParams.year" 
        format="yyyy"
        value-format="yyyy"
        type="year" placeholder="选择年份搜索">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="serachFn"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="deptList">
      <el-table-column
        prop="ranking"
        label="排行榜"
      ></el-table-column>
      <el-table-column
        prop="year"
        label="年份"
      ></el-table-column>
      <el-table-column prop="areaName" label="片区名称" >
      </el-table-column>
      <el-table-column prop="rewardPoints" label="总积分数量" >
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {integralListApi} from "@/api/party/integral"
export default {
  data() {
    return {
      loading: false,
      deptList: [],
      total: 0,
      queryParams: {
        year:"",
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    serachFn() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    resetQuery(){
      this.queryParams.year = "";
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getList() {
      this.loading = true;
      integralListApi(this.queryParams).then((res) => {
        this.deptList = res.rows;
        this.total = res.total;
      }).finally(() => {
        this.loading = false;
      });
    },
  },
};
</script>
